<template>
  <div
    class="btn"
    :class="{
      success: type == 'success',
      primary: type == 'primary',
      danger: type == 'danger',
    }"
    @click="handlerClick"
  >
    <span class="icon"></span>
    <!-- 添加插槽，让用户可以自定义按钮的文本内容 -->
    <!-- 匿名插槽 -->
    <slot></slot>
  </div>
</template>

<script>
export default {
  props: ["icon"],
  props: {
    type: {
      type: String,
    },
  },
  methods: {
    handlerClick(e) {
      // 子组件无法进行具体的业务处理，所以只能告诉父组件需要触发的组件
      //   console.log(e);
      this.$emit("click", e);
    },
  },
};
</script>

<style lang="less" scoped>
.btn {
  width: 318 * 100vw/360;
  height: 50px;
  border-radius: 25px;
  border: 1pc solid #ccc;
  background-color: #ccc;
  line-height: 50px;
  text-align: center;
  margin: 0 auto;
  font-size: 20px;
  color: #666;
  margin: 0 auto;
}
.primary {
  border: 1px solid rgb(67, 145, 4);
  background-color: rgb(67, 145, 4);
  color: #fff;
}
.danger {
  border: 1px solid rgb(211, 29, 13);
  background-color: rgb(211, 29, 13);
  color: #fff;
}
.success {
  border: 1px solid rgb(51, 84, 230);
  background-color: rgb(51, 84, 230);
  color: #fff;
}
</style>